%{
#include <stdio.h>
#include <string.h>
#include "push.h"
extern FILE * yyin;

#define Print(Type,Star,Name) printf("@property (nonatomic, retain) %s %s%s;\n@synthesize %s;\n",Type,Star,Name,Name);

%}


%union
 {
  int number;
  char *string;
 }

%token <string> WORD
%token CLASS CONST STAR LP RP LB RB COLON DOT SEMICOLON COMMA LT GT
%token PUBLIC PRIVATE

%%

All:
| All CppClass
;

CppClass:
class_header LB expressions RB ObjectNames SEMICOLON {}
;

class_header:
CLASS WORD {printf("class name: %s\n",$2);}
|CLASS WORD COLON WORDLISTS {printf("class name: %s\n",$2);}
;
WORDLISTS:
|WORD {printf("%s\n",$1);}
|WORDLISTS COMMA WORD {printf("%s\n",$3);}
;
ObjectNames:
|WORDLISTS
;

expressions:
|general_expressions 
;
access_specifier:
PUBLIC
|PRIVATE

general_expressions:
decl_member 
|decl_function  {printf("decl function expression");}
|access_specifier COLON
|general_expressions decl_member 
|general_expressions decl_function
|general_expressions access_specifier COLON
;
decl_member:
WORD WORDLISTS SEMICOLON {printf("%s",$1);}
|WORD STARS WORDLISTS SEMICOLON {printf("%s",$1);}
;
decl_function:
constructor SEMICOLON
|WORD WORD LP parameters RP const_decl SEMICOLON {printf("%s",$2);}
;
constructor:
WORD LP parameters RP const_decl {printf("%s\n",$1);}
;
parameters:
|parameter
|parameters COMMA parameter
;
parameter:
WORD WORD
|WORD STARS WORD
;
STARS:
|STAR
|STARS STAR
;
const_decl:
|
CONST
;

%%

int yywrap()
{

  return 1;
}

int main(void) {
  int yydebug = 1;
  yyin = fopen("test.txt","r"); 
  yyparse();
  
  fclose(yyin);
  return 0;
}
